package tony.com.xframe.acitivity;

import android.os.Bundle;
import android.view.View;

import com.umeng.update.UmengUpdateAgent;
import com.zhy.autolayout.AutoLayoutActivity;

import im.fir.sdk.FIR;
import tony.com.xframe.AppManager;
import tony.com.xframe.BaseApplication;

/**
 * 基类activity
 * Created by Tony on 2015-12-31.
 */
public abstract class BaseActivity extends AutoLayoutActivity implements View.OnClickListener {

    /**
     * 获取加载View的ID
     *
     * @return
     */
    public abstract int getLayoutId();

    /**
     * 实例化控件
     */
    public abstract void initWidge();

    /**
     * 控件的点击事件
     *
     * @return
     */
    public abstract void widgeClick(int viewId);

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(getLayoutId());
        if(BaseApplication.ALERT_UPDATE){
            UmengUpdateAgent.update(this);
            BaseApplication.ALERT_UPDATE=false;
        }

        FIR.init(this);//BUGHD实例化
        AppManager.getInstance().addActivity(this);
        initWidge();
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onRestart() {
        super.onRestart();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        AppManager.getInstance().finishActivity(this);
    }

    @Override
    public void onClick(View v) {
        widgeClick(v.getId());
    }
}
